home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / bin / btreannounce.bittorrent < prev    next >
Encoding:
Text File  |  2007-02-19  |  651 b   |  24 lines

  1. #! /usr/bin/python
  2.  
  3. # Written by Henry 'Pi' James and Bram Cohen
  4. # see LICENSE.txt for license information
  5.  
  6. from sys import argv
  7. from BitTorrent.bencode import bencode, bdecode
  8.  
  9. if len(argv) < 3:
  10.     print '%s http://new.uri:port/announce file1.torrent file2.torrent' % argv[0]
  11.     print
  12.     exit(2) # common exit code for syntax error
  13.  
  14. for f in argv[2:]:
  15.     h = open(f, 'rb')
  16.     metainfo = bdecode(h.read())
  17.     h.close()
  18.     if metainfo['announce'] != argv[1]:
  19.         print 'old announce for %s: %s' % (f, metainfo['announce'])
  20.         metainfo['announce'] = argv[1]
  21.         h = open(f, 'wb')
  22.         h.write(bencode(metainfo))
  23.         h.close()
  24.